from bisect import  bisect_right
from typing import List


class Solution:
    def answerQueries(self, nums: List[int], queries: List[int]) -> List[int]:
        # 前缀和 排序 二分查找 + 贪心
        nums.sort()
        # 求前缀和
        for i in range(1, len(nums)):
            nums[i] += nums[i - 1]
        for i,q in enumerate(queries):
            #right >target left>=taget 第一个索引
            queries[i]=bisect_right(nums,q)#-1+1
        return queries
